<?php
require_once('../phplib/include.inc.php');
require_once('../phplib/util/CheckLogin.inc.php');

class Admin_Modifyarticle{
	public function DoModify(){
		$picPath = Util::SavePic('picture');
		$R = $_REQUEST;
		$a_id = intval($R['a_id']);
		$c_id = intval($R['category']);
		$a_title = trim($R['title']);
		$a_content = $R['content'];
		$a_abstract = $R['abstract'];
		$arr = array($c_id,$a_title,$a_content,$a_abstract,$a_id);
		$sql = "UPDATE article SET c_id={0},a_title={1},a_content={2},a_abstract={3} WHERE a_id={4}";
		if(strlen($picPath) > 5){
			$sql = "UPDATE article SET c_id={0},a_title={1},a_content={2},a_pic={3},a_abstract={4} WHERE a_id={5}";
			$arr = array($c_id,$a_title,$a_content,$picPath,$a_abstract,$a_id);
		}
		$db = getDb();
		if(!$db->Execute($sql,$arr)) PageBase::Error("unknow error");
		PageBase::Go("../admin/index.php");
	}
}
$a = new Admin_Modifyarticle();
$a->DoModify();
?>